package com.itany.shop.service.impl;

import com.itany.shop.dao.ProductDao;
import com.itany.shop.entity.Product;
import com.itany.shop.factory.ObjectFactory;
import com.itany.shop.service.ProductService;
import com.itany.shop.util.PageInfo;

import java.util.List;

/**
 * @author MissChen
 * @date 2024年04月01日 8:56
 */
public class ProductServiceImpl implements ProductService {
    private ProductDao productDao= (ProductDao) ObjectFactory.getObject("productDao");
    @Override
    public List<Product> findAll() {
        List<Product> products=productDao.selectAll();
        return products;
    }

    @Override
    public PageInfo<Product> findPage(int pageNo, int pageSize) {
        //获取数据的总量
        int total=productDao.selectCount();

        //获取当前页数据
        List<Product> products=productDao.selectPage(pageNo,pageSize);

        //封装成分页对象
        PageInfo<Product> productPageInfo=new PageInfo<>(total,pageNo,pageSize,products);
        return productPageInfo;
    }
}
